<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue生命周期</title>
    <script src="https://cdn.bootcss.com/vue/2.6.11/vue.js"></script>
    <script>
        window.onload = function(){
            var vm = new Vue({
                el:'#mydiv',
                data:{
                    num:10
                },
                methods:{},
                //生命周期函数是Vue的选项
                beforeCreate(){
                    console.log('Vue实例创建之前。。')
                },
                created(){
                    console.log('Vue实例创建完成')
                },
                beforeMount(){
                    console.log('Vue实例挂载DOM元素之前。。')
                },
                mounted(){
                    console.log('Vue实例完成挂载DOM元素。。')
                },
                beforeUpdate(){
                    console.log('Vue实例数据变化前。。')
                },
                updated(){
                    console.log('Vue实例数据完成变化。。')
                }
            })
        }
    </script>
</head>
<body>
    <div id="mydiv">
        <span>{{num}}</span>
        <button @click='num++'>更新数据</button>
    </div>
</body>
</html>